/** \file ChandeOscillator_t.cc 
 * Test definitions for the ChandeOscillator function
 *
 * (c) Copyright by Semih Cemiloglu
 * All rights reserved, see COPYRIGHT file for details.
 *
 * $Id: ChandeOscillator_t.cc 119 2006-06-21 04:57:25Z semihc $
 *
 *
 */


#include "ChandeOscillator.hpp"
#include <vector>
#include <list>
#include "Stock.hpp"
#include "SecurityAdaptor.hpp"
#include "TestHarness.hh"

using namespace std;
using namespace TC;

namespace {

  const unsigned DataSize = 50;

  const double data_cls[DataSize] = {
    51.0625, 50.1250, 52.3125, 52.1875, 53.1875, 53.0625, 54.0625,
    53.5000, 51.5625, 51.5000, 53.2500, 51.8750, 52.0000, 52.5000,
    52.8750, 52.8750, 52.8125, 52.6250, 50.8750, 49.3125, 50.0000,
    49.1250, 47.9375, 49.0000, 50.0625, 50.7500, 50.7500, 51.0625,
    50.1875, 50.3750, 50.4375, 49.8125, 49.6875, 49.8125, 49.3750,
    50.4375, 50.7500, 50.9375, 51.0000, 47.6875, 48.1250, 49.3125,
    49.5000, 50.2500, 50.0000, 50.3750, 49.0000, 48.6875, 48.9375,
    49.7500 };
   

  const double data_expect[DataSize] = {
    0, 0, 0, 0, 0, 45.7143, 88.7324, 42.2222, -13.5135, -45.7627,
    3.5294, -38.4615, -28.5714, 24.5902, 33.3333, -15.7895, 88.2353,
    55.5556, -68.4211, -100.0000, -67.6471, -72.8395, -77.3196, 
    -34.8837, 15.3846, 15.3846, 40.6250, 100.0000, 40.4255, 15.1515,
    -21.7391, -45.4545, -73.3333, -33.3333, -72.7273, 0.0000, 45.4545,
    58.8235, 57.5758, -34.1772, -53.6232, -27.7108, -27.7108, -12.7660,
    82.2222, 81.8182, -10.6383, -26.5306, -51.2195, -8.0000 };

}

TEST(ChandeOscillatorTest, Base)
{
     StockDef s;
     list<StockDef> stocks;
     vector<double> result;
     
     for(unsigned i=0; i<DataSize; ++i) {
       s.setCls(static_cast<StockDef::Price_t>(data_cls[i]));
       stocks.push_back(s);
     }

     ChandeOscillator(stocks.begin(), stocks.end(), 
		      back_inserter(result), 5,
		      SecurityAdaptor<StockDef>());

     TC_TEST(result.size()==DataSize);
     PrintElements(result, "ChandeOscillator");

     for(unsigned i=0; i<DataSize; ++i)
       if(data_expect[i] > 0)
         TC_TESTFP(data_expect[i], result[i]);


}

  


